package org.odefu.model.project;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public final class Project implements Named
{
	private final List<Table> tables = new ArrayList<Table>();

	private final String name;

	Project(final String name)
	{
		this.name = name;
	}

	@Override
	public String name()
	{
		return name;
	}

	public Table createTable(final String name)
	{
		final Table table = new Table(name);
		add(table);
		return table;
	}

	public List<Table> tables()
	{
		return Collections.unmodifiableList(tables);
	}

	public Table table(final int index)
	{
		return tables.get(index);
	}

	public void add(final Table table)
	{
		if (!tables.contains(table))
		{
			tables.add(table);
		}
	}

	public void add(final Table table, final int index)
	{
		if (!tables.contains(table))
		{
			tables.add(index, table);
		}
	}

	public Table remove(final int index)
	{
		return tables.remove(index);
	}

	public boolean remove(final Table table)
	{
		return tables.remove(table);
	}
}
